import {defineStore} from "pinia";

export const useNowRouterStore = defineStore("nowRouterStore",{
    state:() => {
        return{
            name:'首页',
            router:'/main/home',
            indexPath:[],
            tags:[]
        }
    },
    getters:{},
    actions:{
        setName(name){
            this.name = name;
        },
        setRouter(url){
            this.router = url;
        },
        setIndexPath(path){
            this.indexPath = path
        },
        addTags(tags){
            this.tags.push(tags)
        },
        deleteTags(tags){
            if (tags.name === '首页'){
                return
            }
            this.tags = this.tags.filter(item => tags.name !== item.name)
        },
        findTags(name){
            if (!name) return
            return this.tags.findIndex(item => item.name === name)
        },
        clean(){
            this.name = '首页'
            this.router = '/main/home'
            this.indexPath = []
            this.tags = []
        }
    },
    persist:true
})
